package com.dc.free.db.service;

import com.dc.free.db.model.CAction;

public class CAtionService {
	
	private static CAction dao = CAction.dao;
	
	/**
	 * 获取第一个激活活动，如果都未激活，获取第一个活动
	 * @return
	 */
	public static CAction getFirstActivatedAction() {
		CAction action = dao.findFirst("select * from c_action where is_activated=1");
		if(action != null) return action;
		
		return getFirstAction();
	}
	
	/**
	 * 获取第一个活动
	 * @return
	 */
	public static CAction getFirstAction() {
		return dao.findFirst("select * from c_action limit 1");
	}

	public static CAction getAction(String actionId) {
		return dao.findById(actionId);
	}
	
}
